package com.songsf.learn.service;

import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.AsyncResult;
import org.springframework.stereotype.Service;

import java.util.concurrent.Future;

/**
 * Created by songsf on 2017/11/17.
 */
@Service
public class AsynchService {

    @Async
    public Future<String> otherOperate(){

        for (int i = 0 ; i < 10 ; i ++){
            System.out.println("其他处理  "+i);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        return new AsyncResult<>("success");
    }
}
